<?php
namespace app\index\controller;
use think\facade\View;
use think\facade\Cache;
use think\facade\Cookie;
use think\facade\Session;
use app\common\controller\Index as IndexController;
use app\common\controller\Ajax as AjaxController;
class Index extends Base
{
    public function index()
    {
        $this->sub_website();
        return View::fetch();
    }
    public function sub_website($alias='')
    {
        $this->footer_count_sum();
        $SubWebsiteData=Cache::get('SubWebsiteData');
        if (!$alias)
            $alias=request()->subDomain();
        if (!empty($SubWebsiteData[$alias])) {
            $Find=$SubWebsiteData[$alias];
            View::assign('sub_title',$Find['title']);
            View::assign('logo',$Find['logo']);
            View::assign('webtitle',$Find['seo_title']);
            View::assign('keywords',$Find['seo_keywords']);
            View::assign('description',$Find['seo_description']);
            return false;
        }else{
            $alias=request()->rootDomain();
            if (!empty($SubWebsiteData[$alias])) {
                $Find=$SubWebsiteData[$alias];
                View::assign('sub_title',$Find['title']);
                View::assign('logo',$Find['logo']);
                View::assign('webtitle',$Find['seo_title']);
                View::assign('keywords',$Find['seo_keywords']);
                View::assign('description',$Find['seo_description']);
                return false;
            }
        }
        return View::fetch();
    }
    public function footer_count_sum()
    {
        View::assign('footer_count_sum',AjaxController::getHomeStatistics());
    }
    public function map_jobs()
    {
        return View::fetch();
    }
    public function maintenance()
    {
    	$G=request()->get();
        $msg='';
        if (!empty($G)) {
            $msg=$G['msg'];
        }
    	View::assign('message',$msg);
    	return View::fetch();
    }
    public function downInternetShortcut()
    {
        $G=request()->get();
        $url=empty($G['url'])?config('web.url'):config('web.url').$G['url'];
        $title=empty($G['title'])?config('web.name'):$G['title'];
        $content="[{000214A0-0000-0000-C000-000000000046}]\nProp3=19,11\n[InternetShortcut]\nURL=".$url."\nIconFile=".config('web.url')."/favicon.ico";
        return download($content,$title.'.url',true)->expire(5);
    }
}
